define(['./module'], function (services) {
  'use strict';
  services.factory('Common', ['$resource', function ($resource) {
    return function (module, params, offline) {
      if (params == null) {
        params = {};
      }
      if (offline == null) {
        offline = true;
      }
      if (offline) {
        return $resource('data/' + module + '/:id.json', params, {
          query: {
            method: 'GET',
            params: {
              id: 'list'
            },
            isArray: false
          },
          get: {
            method: 'GET',
            params: {
              id: '1'
            }
          }
        });
      } else {
        return $resource('api/' + module + '/:id', params, {
          query: {
            method: 'GET',
            isArray: false
          },
          update:{
            method:'PUT'
          }
        })
      }
    };
  }]);
});
